Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

249
Visualizações
How to use package with js? Installed the package, but getting: “SyntaxError: Cannot use import statement outside a module”

This is my first time using js so bear with me (I’m an experienced python programmer).

How am I supposed to use this repo in js: https://github.com/omerdn1/otter.ai-api

I installed the package with npm and created the setup script (and updated it to fit my login info), but I’m getting a SyntaxError: SyntaxError: Cannot use import statement outside a module at the first line import OtterApi from 'otter.ai-api';.

I looked at the similar SO questions (1 and 2) and the solution seems to be adding ”type”: “module” to the package.json file. But 1) I’m not sure if they actually me “module” or its a specific module name 2) I tried this with both “module” and “OtterApi” and I’m still getting the SyntaxError.

I’m totally lost. Don’t know how modules work in js. Would greatly appreciate your help. :)

Edit: I replaced the import with the following instead: const OtterApi = require('otter.ai-api')

This seems to work as the initial error is no longer there. However, I’m now getting a separate SyntaxError (which is may be unrelated to the first error?): SyntaxError: await is only valid in async functions and the top level bodies of modules.

This is from the following code:

const OtterApi = require(‘otter.ai-api’);

const otterApi = new OtterApi({
  email: 'email@example.com', // Your otter.ai email
  password: 'abc123!#', // Your otter.ai password
});

await otterApi.init() // Performs login

The error happens at the last line.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I used the setup code, but I replaced the import with the following instead: const OtterApi = require('otter.ai-api').

Apparently, you can’t use ES Modules in Node without jumping through some hoops (or maybe using the latest version?). So, the above resolves that issue.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda